﻿using Spire.Xls;

using System.Data;
using Spire.Xls;


namespace luck_roll
{
    /// <summary>
    /// Excel工具类
    /// </summary>
    public class ExcelHelper
    {
        /// <summary>
        /// 读取Excel数据
        /// </summary>
        /// <param name="filePath">文件地址</param>
        /// <returns></returns>
        public static List<string> ReadExcelData(String filePath)
        {

            List<string> list = new List<string>();

            if (File.Exists(filePath))
            {
                // 加载Excel文件
                Workbook workbook = new Workbook();
                workbook.LoadFromFile(filePath);

                // 获取第一个工作表
                Worksheet worksheet = workbook.Worksheets[0];

                // 遍历行和列读取数据
                for (int row = 0; row < worksheet.Rows.Length; row++)
                {
                    string value = worksheet.Rows[row].Cells[0].Value;
                    list.Add(value);
                }

            }

            return list;

        }
    }
}
